<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html lang="en">
<head>
<base href="<%=basePath%>">
<meta charset="utf-8" />
<title>添加邮差</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="stilearning" />

<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/bootstrap-responsive.css" rel="stylesheet" />
<link href="css/stilearn.css" rel="stylesheet" />
<link href="css/stilearn-responsive.css" rel="stylesheet" />
<link href="css/stilearn-helper.css" rel="stylesheet" />
<link href="css/stilearn-icon.css" rel="stylesheet" />
<link href="css/font-awesome.css" rel="stylesheet" />
<link href="css/animate.css" rel="stylesheet" />
<link href="css/uniform.default.css" rel="stylesheet" />

<link href="css/select2.css" rel="stylesheet" />
<link href="css/fullcalendar.css" rel="stylesheet" />
<link href="css/bootstrap-wysihtml5.css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
	<!-- section header -->
	<jsp:include page="courier_head.jsp" />

	<!-- section content -->
	<section class="section">
		<div class="row-fluid">
			<!-- span side-left -->
			<jsp:include page="admin_left.jsp" />
			<!-- span side-left -->

			<!-- span content -->
			<div class="span11">
				<!-- content -->
				<div class="content">
					<!-- content-header -->
					<div class="content-header">
						<h2>
							<i class="icofont-home"></i> 添加邮差
						</h2>
					</div>
					<!-- /content-header -->

					<!-- content-body -->
					<div class="content-body">
						<div class="row-fluid">
							<div class="span5 offset3">
								<div class="box-body bg-white">
									<form id="add_poster" method="post" />
									<div class="control-group">
										<label class="control-label">姓名</label>
										<div class="controls">
											<input id="cname" type="text" class="input-block-level"
												data-validate="{required: true, messages:{required:'Please enter field username'}}"
												autocomplete="off" />
											<p class="help-block muted helper-font-small"></p>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">联系电话</label>
										<div class="controls">
											<input id="tel" type="text" class="input-block-level"
												data-validate="{required: true, number:true, messages:{required:'Please enter field tel', email:'Please enter a valid tel'}}"
												autocomplete="off"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
											<p class="help-block muted helper-font-small">
												<strong></strong>
											</p>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">Email</label>
										<div class="controls">
											<input id="email" type="text" class="input-block-level"
												data-validate="{required: true, number:true, messages:{required:'Please enter field tel', email:'Please enter a valid tel'}}"
												autocomplete="off" />
											<p class="help-block muted helper-font-small">
												<strong></strong>
											</p>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">基本工资</label>
										<div class="controls">
											<input id="salary" type="text" class="input-block-level"
												data-validate="{required: true, number:true, messages:{required:'Please enter field tel', email:'Please enter a valid tel'}}"
												autocomplete="off" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">权限</label>
										<div class="controls">
											<input type='radio' id='permission' name='permission'
												value='0' />管理员 <input type='radio' id='permission'
												name='permission' value='1' />普通邮差
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">密码</label>
										<div class="controls">
											<input id="passwd" type="password" readonly value="000000"
												class="input-block-level"
												data-validate="{required: true, minlength: 6, messages:{required:'Please enter field password', minlength:'Please enter at least 6 characters.'}}"
												autocomplete="off" />
											<p class="help-block muted helper-font-small">默认为6个000000</p>
										</div>
									</div>
									<div>
										<button type="button" class="btn btn-large btn-block btn-inverse" onclick="myFunction()" >提交</button>
									</div>
									</form>
								</div>

							</div>
							<!--/Sign Up-->
							<!-- /span -->
						</div>
						<!--Sign Up-->

					</div>
					<!--/content-body -->
				</div>
				<!-- /content -->
			</div>
			<!-- /span content -->

		</div>
	</section>

	<!-- section footer -->
	<footer>
		<a rel="to-top" href="#top"><i class="icofont-circle-arrow-up"></i>
		</a>
	</footer>

	<!-- javascript
        ================================================== -->
	<!--<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>-->
	<script src="js/jquery.js"></script>
	<script src="js/jquery-ui.min.js"></script>
	<script src="js/bootstrap.js"></script>
	<script src="js/uniform/jquery.uniform.js"></script>
	<script src="js/peity/jquery.peity.js"></script>

	<script src="js/select2/select2.js"></script>
	<script src="js/knob/jquery.knob.js"></script>
	<script src="js/flot/jquery.flot.js"></script>
	<script src="js/flot/jquery.flot.resize.js"></script>
	<script src="js/flot/jquery.flot.categories.js"></script>
	<script src="js/wysihtml5/wysihtml5-0.3.0.js"></script>
	<script src="js/wysihtml5/bootstrap-wysihtml5.js"></script>
	<script src="js/calendar/fullcalendar.js"></script>
	<!-- this plugin required jquery ui-->

	<!-- required stilearn template js, for full feature-->
	<script src="js/holder.js"></script>
	<script src="js/stilearn-base.js"></script>

	<script type="text/javascript">
		function myFunction() {
			//	alert(parcel_id);
			var cname = $('#cname').val();
			var tel = $('#tel').val();
			var email = $('#email').val();
			var salary = $('#salary').val();
			var permission = $(':radio[name="permission"]:checked').val();  //获取选中的radio的值
			var pwd = $('#pwd').val();
			if (cname != null && tel != null && email != null && salary != null
					&& permission != null) {
				$.ajax({
					url : "registCourier",
					dataType : "json",
					type : "post",
					data : {
                        "cname":cname,
                        "tel":tel,
                        "email":email,
                        "salary":salary,
                        "permission":permission,
                        "pwd":pwd
					},
					success : function(data) {
						var r = eval("(" + data + ")");
						alert(r.result);
					},
					error : function() {
						//请求出错处理   
						alert("fuck error");
					}
				});
			}else{
			   alert("请输入完整信息！！");
			}
		}
	</script>

</body>
</html>
